package ru.amse.stroganova.ui.tool;

import java.awt.event.MouseEvent;

import ru.amse.stroganova.presentation.VertexPresentation;
import ru.amse.stroganova.ui.GraphComponent;
import ru.amse.stroganova.ui.command.Command;

/*package*/ class AddVertexTool extends Tool {

	private final GraphComponent component;

	/*package*/ AddVertexTool(GraphComponent component) {
		this.component = component;
	}

	@Override
	public void mousePressed(MouseEvent e) {
		//XXX Forbids creating vertices that don't wholly lay whithin borders. After autoscrolling refactor.
		if (e.getPoint().x < VertexPresentation.RADIX
				|| e.getPoint().y < VertexPresentation.RADIX) {
			return;
		}
		Command command = component.getCommandFactory().getNewAddVertexCommand(
				e.getPoint());
		component.addCommand(command);
		command.execute();
	}
}
